import React from 'react';

export default class extends React.Component {

  state = {
    visible: true,
  };

  toggle () {
    this.setState({
      visible: !this.state.visible,
    });
  }

  // 渲染
  render () {
    // jsx语法
    return (
      <div>
        { this.state.visible && <span>hello world</span> }
        <button onClick={ this.toggle.bind(this) }>
          { this.state.visible ? '隐藏' : '显示' }
        </button>
      </div>
    );
  }

}
